/*
 * Main.fx
 *
 * Created on 07.11.2009, 20:09:42
 */

package src.javafx179labs.Nazarov.lab4;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.animation.Timeline;
import javafx.scene.transform.Rotate;
import javafx.scene.input.MouseEvent;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import javafx.scene.text.Text;
import javafx.scene.text.Font;


var leftHandAngle = 0;
var rightHandAngle = 0;
var rightHandAngle2 = 0;
var x=220;
var y=185;
var x1=370;



//objects
var start : Circle = Circle{
    radius: 40
    centerX:200
    centerY:500
    fill: Color.RED
    onMouseClicked: function(evt: MouseEvent):Void{
        timeline.playFromStart();
    }
}


var gear : Rectangle = Rectangle{
    x: bind x1
    y: 510
    width: 30
    height: 7
    fill: Color.BROWN

}

var taxometr : Rectangle = Rectangle{
    x: 200
    y: 355
    width: 300
    height: 15
    fill: Color.RED
    transforms: [
            Rotate{
                pivotX:480
                pivotY:355
                angle: bind rightHandAngle
            }
    ]
}

var speed : Rectangle = Rectangle{
    x: 750
    y: 250
    width: 170
    height: 15
    fill: Color.RED
    transforms: [
            Rotate{
                pivotX: 900
                pivotY: 250
                angle: bind rightHandAngle2
            }
    ]
}
var timeline : Timeline = Timeline{
    repeatCount:4
    autoReverse:true
    keyFrames: [
         at(0s){
           rightHandAngle => 0;
           rightHandAngle2 => -45;
         }

 at(0.3s){
           rightHandAngle => 10;
           rightHandAngle2 => -45;
         }

at(1s){
           rightHandAngle => 10;
           rightHandAngle2 => -45;
         }
at(1.5s){
           rightHandAngle => 10;
           rightHandAngle2 => -45;
           x1=> 483;
         }

 at(2s){
          rightHandAngle => 10;
          rightHandAngle2 => -45;
           
         }
 at(3s){
          rightHandAngle => 55;
          rightHandAngle2 => -25;
         }
 at(4.7s){
           rightHandAngle => 90;
           rightHandAngle2 => 10;

         }

  at(5s){
           rightHandAngle => 30;
           rightHandAngle2 => 5;

         }
  at(6s){
           rightHandAngle => 70;
           rightHandAngle2 => 30;

         }

  at(7s){
           rightHandAngle => 90;
           rightHandAngle2 => 55;

         }

  at(7.3s){
           rightHandAngle => 30;
           rightHandAngle2 => 50;

         }

at(8.0s){
           rightHandAngle => 65;
           rightHandAngle2 => 75;
         }
at(9.0s){
           rightHandAngle => 90;
           rightHandAngle2 => 110;

         }
at(9.3s){
           rightHandAngle => 40;
           rightHandAngle2 => 105;

         }
 at(10.4s){
           rightHandAngle => 75;
           rightHandAngle2 => 140;

         }
  at(12s){
           rightHandAngle => 90;
           rightHandAngle2 => 170;

         }

  at(12.3s){
           rightHandAngle => 40;
           rightHandAngle2 => 165;

         }
  at(13.3s){
           rightHandAngle => 65;
           rightHandAngle2 => 185;

         }
   at(14.2s){
           rightHandAngle => 90;
           rightHandAngle2 => 200;

         }
    at(14.5s){
           rightHandAngle => 50;
           rightHandAngle2 => 190;
         }

   at(17s){
           rightHandAngle => 90;
           rightHandAngle2 => 240;
         }
         
        ]
}




Stage {
    title: "Acseleracion"
    width: 500
    height: 500
    scene: Scene {
        content: [

                ImageView {
        image: Image {
                url: "http://djzlat.land.ru/pribor.jpg"
        }
}

 start,
Text {
        font : Font {
                size: 20
        }
        fill: Color.WHITE
        x: 178, y: 505
        content: "Start"
}

            gear,
            taxometr,
            speed,


        ]
    }
}